package  
{
  import com.bit101.components.Label;
  import com.bit101.components.PushButton;
  import flash.display.Sprite;
  import flash.display.StageAlign;
  import flash.display.StageScaleMode;
  import flash.events.Event;
  import flash.net.SharedObject;
	/**
   * ...
   * @author ivan
   */
  public class SaveGame extends Sprite
  {
    
    private const SAVE_CATEGORY_FOO:String = "MySavedData";
    public function SaveGame() 
    {
      stage.scaleMode = StageScaleMode.NO_SCALE;
      stage.align = StageAlign.TOP_LEFT;
      stage.stageFocusRect = false;
      
      var shared:SharedObject = SharedObject.getLocal(SAVE_CATEGORY_FOO);
      
      new PushButton(this, 0, 20, "B1", onB1Push);
      new PushButton(this, 0, 40, "B2", onB2Push);
      
      var text:Label = new Label(this, 0, 0, "Last Button Pressed: " + shared.data.lastButton + ".");
    }
    
    private function onB1Push(e:Event):void
    {
      var shared:SharedObject = SharedObject.getLocal(SAVE_CATEGORY_FOO);
      shared.data.lastButton = 1;
    }
    
    private function onB2Push(e:Event):void
    {
      var shared:SharedObject = SharedObject.getLocal(SAVE_CATEGORY_FOO);
      shared.data.lastButton = 2;
    }
    
  }

}